
/*
 * 
 * all list �먯꽌 sor t �곸슜  
 : h , n filter �곸슜 :  
  == ��긽 �숈씪 array �섏삱�� 
  臾몄젣��fav ���숆린 留욎텛湲�.
  �닿굔 �쇰떒, 臾댁떆�섍린. undef �섏삤��鍮덈룄 蹂닿퀬 異붽� �섍린.. ( ��time ��) 
 
 * �섎굹���섑뻾�섎㈃��pop �섎㈃ �좊벏.3
 * 
 * 
	*6star arr �먯꽌, 
�먭린 醫뚰몴 嫄곕━ �쒖쑝濡�sort �섍린. 
 hn ���곕Ⅸ �꾪꽣 �곸슜 : 
   - �놁쑝硫�list �먯꽌 吏�슦湲� 
   - all h 留��④린湲� 
 ** filtered list �먯꽌 per 5 �� fav �섏뼱����
   : 嫄곕━��sort �섎㈃, list 媛��숈씪�댁쭚.
  : �� filter �듭뀡��蹂�꼍�섎㈃, list index �щ씪吏� 
 : filtered list 異쒕젰�섍린. 
  : index �щ씪吏�㈃, dummy �쇰룄 異붽��댁빞 ����. 
*/
// ready 
// : �좎룞�쇿뜝占썲뜝�숈삕�좎룞�쇿뜝占�
// : evt handler �좎룞�쇿뜝�숈삕閭먨뜝占�
// : �좎떗源띿삕 �좎룞�숈껜 �좎룞�쇿뜝�밴퉵�� 
$(document).ready(function() {

	// cbs 
		em.cbs= {};
		
		// for cstl move & wave 
		em.cbs.cstlmove1done = $.Callbacks( "unique stopOnFalse" );	
		em.cbs.cstlwavedone = $.Callbacks( "unique stopOnFalse" );
		
			
		// login new user : got new key 
		em.cbs.userlogin = $.Callbacks("unique stopOnFalse");
		
		// when completed select new user : start GM  -> new login : get system task api :: then fire . :  reset all prev datas  
		em.cbs.userchanged = $.Callbacks("unique stopOnFalse");
			// when start user change :  to notify free prev resource  
		em.cbs.startuserchange = $.Callbacks("unique stopOnFalse");
		
		// all hero list update
		em.cbs.heroupdate = $.Callbacks("unique stopOnFalse");
		// hnting avaliable h list update 
		em.cbs.warableHpdate = $.Callbacks("unique stopOnFalse");
		
		// hnt  : 1 da hnt 1 time end cb  for cals end time : decide next ctsl
		em.cbs.hntdone = $.Callbacks("unique stopOnFalse");
		// 1 cstl att is done !!
		em.cbs.autoCstlAttDone = $.Callbacks("unique stopOnFalse");  
		// update cstl 's sols '
		em.cbs.updatesols = $.Callbacks("unique stopOnFalse");
		
		// sols trained finished  
		em.cbs.soltraindone = $.Callbacks("unique stopOnFalse");
		
		// global contorl cb 
		em.cbs.forcestop = $.Callbacks("unique stopOnFalse");
		
		// timer for desc time info  
		em.cbs.sectimer = $.Callbacks("unique stopOnFalse");
		
		
	// global 
		// var users = CDB.users;//[ 'james', 'greate'];
		// var devices = CDB.devices;//['iphone', 'android' ] ;
		
	em.cstlview = new CCstlView();
	em.cstlview.initialize();

	em.infoview = new CInfoView();
	em.infoview.initialize();
	
	em.cstlmgr = new CCstlMgr();
	em.cstlmgr.cstlwave_initialize();
	em.cstlmgr.setView(em.cstlview);
	


	em.query = new CQuery();
	em.query.initialize();

	em.util = new CUtil();
		
	em.tasks = new CTasks();
	
	em.worldDA = new CWorldDA();
	
/*
	if ( CDB.getCurUserOptions().hntmgr ==  2 ) {
		em.hntmgr = new CHuntMgr2();
	}else {
		em.hntmgr = new CHuntMgr();
	}
	em.hntmgr.initialize();
*/
	
	em.controller = new CController();
	
	em.scaning = new CScaning();
	em.scaning.initialize();


	
	em.hdrinmgr = new CHDrinMgr();
	
	
	// start monotor !!
	em.jobmonitor.registerCBs();
	em.jobmonitor.startMonitor();
	/*
		panel...
	*/

	


	
	//======================= TEST code here ========================
	// set login defualt user 'Greateload' for test 
	// em.controller.login('Greateload');
		
	em.infoview.connected();
	
	console.log( $.now());
	
	/*
		stroage util test 
	*/
	
	// var ret = JSON.parse('thingtest_string');
/*
	var ret2 = JSON.stringify({a: 'ttt', b: 222});
	console.log(ret2 );
	
	var ret3 = JSON.parse(ret2);
	console.log( ' get strogate : ' , ret3);

	var ret4 = JSON.stringify('test_string');
	console.log(ret4 );
	
	var ret5 = JSON.parse(ret4);
	console.log( ' get strogate : ' , ret5);

	
	CUtil.saveStorage('test1' , 'sring_value');
	console.log(CUtil.getStorage ('test1') );

	// object test 	
	CUtil.saveStorage('test_object' , { a : 'propertya', b: 111111} );
	console.log(CUtil.getStorage ('test_object') );
	
	return;*/

	
/*
	this.lasttime = new Date();
	localStorage.setItem('Fealty_lasttime_' +  CDB.getCurUserName() , this.lasttime.getTime() + 60*1000*20 );
	this.testtime = new Date( this.lasttime.getTime() + 60*1000*20 );
	this.newtime = new Date( parseInt ( localStorage.getItem('Fealty_lasttime_' +  CDB.getCurUserName() ) ) );
	console.log( this.lasttime);
	console.log( this.testtime);
	console.log( this.newtime);*/

	
	
/*
	$("#some-element").bind("main_event", function(event, params) {
    doSomethingKickAss(params);
});*/



/*
  Edit: the next line does not work in some
  browsers but I'm leaving it here so the comments
  on the blog post make sense.
*/
MyObject = {};
if (typeof(MyObject) != "undefined") MyObject = {};
/**
 * Bind a callback to a custom event on MyObject
 */
$(MyObject).bind("main", function(event, theData) {
    alert(theData);
});
/**
 * Now trigger the custom event on the custom object
 */
// $(MyObject).trigger("main", "Welcome to the main event");


/*
	// test code !!
	// send result to UI Veiw
	em.cstlview.updateHDrin( 1,
		{
		"code":0,"ret":
		{"gold":24148,"price":5135,"refresh":3600,"hero":{"gid":117,"p":11,"i":21,"c1":15,"g":2,"c2":295},"rumor":0}
		});*/

	
	
	// set initial info
	if ( em.test ) {
		$('#mode_indicator').html($('<span>').text('TEST MODE!!')).show();
		$('#mode_indicator').click(function() {
			em.test = false;
			$(this).hide();
		});
	}
	

/*
	test code
*/
/*
		// calulate resorece !!!
		var per_res =  {f:1500, w:4500, i:4500, g:1500};
		var need_res = per_res;
		$.each( Object.keys(need_res) , function (i, item) { 
			need_res[item] *= 100; 
			});
		
		console.log( ' per_res ' , per_res);
		console.log( ' need_res ' , need_res);
		*/

		
		
		
		
		
		
		/*
			 make callbacks  for event...
		*/
		

		/*
			 google panel 
		*/
		
		
		
	console.log( ' Try install Office screen... ');
	if ( em.place == 'office') {
			console.log( ' Cur is Office mode ');
		
		$('#navi_container').click( function(){
			console.log( ' google screend.. ');
			$('#google_screen').toggle();;
		});
	
		$('#google_screen').click( function(){
			console.log( ' google screend.. ');
			$('#google_screen').toggle();;
		});
	}

/*

// 	V Panel 
	$('.trigger').click( function(){
		var id = $(this).attr('href');
		console.log(id);
		$('#extpanel_' + id[1]).toggle('fast');
		// $('#ex1tpanel_1').toggle('fast');
		$(this).toggleClass('active');
		return false;
	});
*/



//   Doc  ..
$(function () { 
	// Dock initialize
	$('#dock').Fisheye(
		{
			maxWidth: 30,
			items: 'a',
			itemsText: 'span',
			container: '.dock-container',
			itemWidth: 50,
			proximity: 60,
			alignment : 'left',
			valign: 'bottom',
			halign : 'center'
	}
	);
});

/*
// STack 
$(function () { 
	// Stack initialize
	var openspeed = 300;
	var closespeed = 300;
	$('.stack>img').toggle( function(){
		//reverse above
		var $el=$(this);
		$el.next().removeClass('openStack').children('li').animate({top: '55px', left: '-10px'}, closespeed);
		$el.next().find('li a>img').animate({width: '79px', marginLeft: '0'}, closespeed);
		$el.animate({paddingTop: '35px'});
	},
		function(){
		var vertical = 0;
		var horizontal = 0;
		var $el=$(this);
		$el.next().children().each(function(){
			$(this).animate({top: '-' + vertical + 'px', left: horizontal + 'px'}, openspeed);
			vertical = vertical + 55;
			horizontal = (horizontal+.75)*2;
		});
		$el.next().animate({top: '-50px', left: '10px'}, openspeed).addClass('openStack')
		   .find('li a>img').animate({width: '50px', marginLeft: '9px'}, openspeed);
		$el.animate({paddingTop: '0'});
	});
	
	// Stacks additional animation
	$('.stack li a').hover(function(){
		$("img",this).animate({width: '56px'}, 100);
		$("span",this).animate({marginRight: '30px'});
	},function(){
		$("img",this).animate({width: '50px'}, 100);
		$("span",this).animate({marginRight: '0'});
	});
});*/

 

/*
  	$("#id_testmode").click( function(e) {
		var configForm = new com.james.config_form;
		configForm.getMode();
   	});*/


	$("#id_getdalist_btn").click( function(e) {
		  });


	$("#id_scrolldown").click( function(e) {
			$('#result_box').animate({scrollTop: $('#result_box')[0].scrollHeight});
	   });


	

   
});
  

myNameSpace = function(){
  var current = null;
  function init(){}
  function change(){}
  function verify(){}
  return{
    init:init,
    set:change
  }
}();

myNameSpace.init();



